History

add --disable-static option to build libtcc.so instead of libtcc.a for distros that want static libs

Henry Kroll III committed 16 years ago

Commit a4ed5871 parent 15783222 files · +33 −10Browse files

Unified · Split

2 files
  1. Makefile +27 −10
  2. configure +6 −0
Makefile+27−10
@@ -8,6 +8,18 @@ include $(TOP)/config.mak · 7 unmodified lines
88 CFLAGS+=-g -Wall
99 CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC
1010 LIBS_P=
11+LIBS=.
12+
13+# My distro wants shared libs, not static ones
14+LIBTCCA=libtcc.a
15+ifdef DISABLE_STATIC
16+CFLAGS+=-fPIC
17+LIBTCCA=
18+LIBTCCL=-ltcc
19+LIBTCCSO=libtcc.so.1
20+endif
21+LIBTCCB=$(LIBTCCA)
22+LIBTCCB+=$(LIBTCCSO)
1123
1224 ifneq ($(GCC_MAJOR),2)
1325 CFLAGS+=-fno-strict-aliasing
@@ -117,11 +129,11 @@ ifdef CONFIG_CROSS · 103 unmodified lines
117129 PROGS+=$(PROGS_CROSS)
118130 endif
119131
120−all: $(PROGS) $(LIBTCC1) $(BCHECK_O) libtcc.a tcc-doc.html tcc.1 libtcc_test$(EXESUF)
132+all: $(PROGS) $(LIBTCC1) $(BCHECK_O) $(LIBTCCB) tcc-doc.html tcc.1 libtcc_test$(EXESUF)
121133
122134 # Host Tiny C Compiler
123−tcc$(EXESUF): tcc.o libtcc.a
124− $(CC) -o $@ $^ $(LIBS)
135+tcc$(EXESUF): tcc.o $(LIBTCCA)
136+ $(CC) -o $@ $^ $(LIBS) $(LIBTCCL)
125137
126138 # Cross Tiny C Compilers
127139 %-tcc$(EXESUF):
@@ -163,8 +175,13 @@ $(LIBTCC_OBJ) tcc.o : %.o : %.c $(LIBTCC_INC) · 35 unmodified lines
163175 libtcc.a: $(LIBTCC_OBJ)
164176 $(AR) rcs $@ $^
165177
166−libtcc_test$(EXESUF): tests/libtcc_test.c libtcc.a
167− $(CC) -o $@ $^ -I. $(CFLAGS) $(LIBS)
178+libtcc.so.1: $(LIBTCC_OBJ)
179+ $(CC) -shared -Wl,-soname,$@ -o $@.0 $^
180+ ln -sf libtcc.so.1.0 libtcc.so.1
181+ ln -sf libtcc.so.1.0 libtcc.so
182+
183+libtcc_test$(EXESUF): tests/libtcc_test.c $(LIBTCCA)
184+ $(CC) -o $@ $^ -I. $(CFLAGS) $(LIBS) $(LIBTCCL)
168185
169186 libtest: libtcc_test$(EXESUF) $(LIBTCC1)
170187 ./libtcc_test$(EXESUF) lib_path=.
@@ -204,7 +221,7 @@ TCC_INCLUDES = stdarg.h stddef.h stdbool.h float.h varargs.h tcclib.h · 33 unmodified lines
204221 INSTALL=install
205222
206223 ifndef CONFIG_WIN32
207−install: $(PROGS) $(LIBTCC1) $(BCHECK_O) libtcc.a tcc.1 tcc-doc.html
224+install: $(PROGS) $(LIBTCC1) $(BCHECK_O) $(LIBTCCB) tcc.1 tcc-doc.html
208225 mkdir -p "$(bindir)"
209226 $(INSTALL) -s -m755 $(PROGS) "$(bindir)"
210227 mkdir -p "$(mandir)/man1"
@@ -219,7 +236,7 @@ ifneq ($(BCHECK_O),) · 8 unmodified lines
219236 endif
220237 $(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include"
221238 mkdir -p "$(libdir)"
222− $(INSTALL) -m644 libtcc.a "$(libdir)"
239+ $(INSTALL) -m644 $(LIBTCCB) "$(libdir)"
223240 mkdir -p "$(includedir)"
224241 $(INSTALL) -m644 libtcc.h "$(includedir)"
225242 mkdir -p "$(docdir)"
@@ -230,7 +247,7 @@ uninstall: · 4 unmodified lines
230247 rm -fv $(foreach P,$(LIBTCC1) $(BCHECK_O),"$(tccdir)/$P")
231248 rm -fv $(foreach P,$(TCC_INCLUDES),"$(tccdir)/include/$P")
232249 rm -fv "$(docdir)/tcc-doc.html" "$(mandir)/man1/tcc.1"
233− rm -fv "$(libdir)/libtcc.a" "$(includedir)/libtcc.h"
250+ rm -fv "$(libdir)/$(LIBTCCB)" "$(includedir)/libtcc.h"
234251
235252 else
236253 install: $(PROGS) $(LIBTCC1) libtcc.a tcc-doc.html
@@ -246,7 +263,7 @@ install: $(PROGS) $(LIBTCC1) libtcc.a tcc-doc.html · 9 unmodified lines
246263 cp -r win32/examples/. "$(tccdir)/examples"
247264 $(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include"
248265 $(INSTALL) -m644 tcc-doc.html win32/tcc-win32.txt "$(tccdir)/doc"
249− $(INSTALL) -m644 libtcc.a libtcc.h "$(tccdir)/libtcc"
266+ $(INSTALL) -m644 $(LIBTCCB) libtcc.h "$(tccdir)/libtcc"
250267 endif
251268
252269 # documentation and man page
@@ -270,7 +287,7 @@ tar: · 17 unmodified lines
270287 $(MAKE) -C tests $@
271288
272289 clean:
273− rm -vf $(PROGS) tcc_p$(EXESUF) tcc.pod *~ *.o *.a *.out libtcc_test$(EXESUF)
290+ rm -vf $(PROGS) tcc_p$(EXESUF) tcc.pod *~ *.o *.a *.out *.so* *.exe libtcc_test$(EXESUF)
274291 $(MAKE) -C tests $@
275292
276293 distclean: clean
configure+6−0
@@ -128,6 +128,8 @@ for opt do · 127 unmodified lines
128128 ;;
129129 --enable-cross) build_cross="yes"
130130 ;;
131+ --disable-static) disable_static="yes"
132+ ;;
131133 --with-libgcc) use_libgcc="yes"
132134 ;;
133135 --with-selinux) have_selinux="yes"
@@ -230,6 +232,7 @@ echo " --source-path=PATH path of source code [$source_path]" · 96 unmodified lines
230232 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
231233 echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"
232234 echo " --cc=CC use C compiler CC [$cc]"
235+echo " --disable-static make libtcc.so instead of libtcc.a"
233236 echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc1.a"
234237 echo " --with-selinux use mmap instead of exec mem"
235238 echo " [requires write access to /tmp]"
@@ -357,6 +360,9 @@ fi · 121 unmodified lines
357360 if test "$build_cross" = "yes" ; then
358361 echo "CONFIG_CROSS=yes" >> config.mak
359362 fi
363+if test "$disable_static" = "yes" ; then
364+ echo "DISABLE_STATIC=yes" >> config.mak
365+fi
360366 if test "$use_libgcc" = "yes" ; then
361367 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
362368 echo "CONFIG_USE_LIBGCC=yes" >> config.mak

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t