Unified · Split
| @@ -1,24 +1,30 @@ | |||
| 1 | # | 1 | # |
| 2 | # Tiny C Compiler Makefile | 2 | # Tiny C Compiler Makefile |
| 3 | # | 3 | # |
| 4 | prefix=/usr/local | 4 | include config.mak |
| 5 | manpath=$(prefix)/man | ||
| 6 | 5 | ||
| 7 | CFLAGS=-O2 -g -Wall | 6 | CFLAGS=-O2 -g -Wall |
| 8 | LIBS=-ldl | 7 | LIBS=-ldl |
| 9 | CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC | 8 | CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC |
| 10 | LIBS_P= | 9 | LIBS_P= |
| 11 | 10 | ||
| 12 | CFLAGS+=-m386 -malign-functions=0 -mpreferred-stack-boundary=2 | 11 | CFLAGS+=-mpreferred-stack-boundary=2 |
| 13 | CFLAGS+=-DCONFIG_TCC_PREFIX=\"$(prefix)\" | 12 | ifeq ($(GCC_MAJOR),2) |
| 13 | CFLAGS+=-m386 -malign-functions=0 | ||
| 14 | else | ||
| 15 | CFLAGS+=-march=i386 -falign-functions=0 | ||
| 16 | endif | ||
| 17 | |||
| 18 | |||
| 14 | DISAS=objdump -d | 19 | DISAS=objdump -d |
| 15 | INSTALL=install | 20 | INSTALL=install |
| 16 | VERSION=0.9.16 | ||
| 17 | 21 | ||
| 18 | # run local version of tcc with local libraries and includes | 22 | # run local version of tcc with local libraries and includes |
| 19 | TCC=./tcc -B. -I. | 23 | TCC=./tcc -B. -I. |
| 20 | 24 | ||
| 21 | all: tcc libtcc1.o bcheck.o tcc-doc.html | 25 | all: tcc libtcc1.o bcheck.o tcc-doc.html libtcc.a libtcc_test |
| 26 | |||
| 27 | Makefile: config.mak | ||
| 22 | 28 | ||
| 23 | # auto test | 29 | # auto test |
| 24 | 30 | ||
| @@ -26,7 +32,7 @@ test: test.ref test.out · 1 unmodified line | |||
| 26 | @if diff -u test.ref test.out ; then echo "Auto Test OK"; fi | 32 | @if diff -u test.ref test.out ; then echo "Auto Test OK"; fi |
| 27 | 33 | ||
| 28 | tcctest.ref: tcctest.c | 34 | tcctest.ref: tcctest.c |
| 29 | gcc $(CFLAGS) -I. -o $@ $< | 35 | $(CC) $(CFLAGS) -I. -o $@ $< |
| 30 | 36 | ||
| 31 | test.ref: tcctest.ref | 37 | test.ref: tcctest.ref |
| 32 | ./tcctest.ref > $@ | 38 | ./tcctest.ref > $@ |
| @@ -96,41 +102,46 @@ speed: tcc ex2 ex3 · 63 unmodified lines | |||
| 96 | time ./tcc -I. ./ex3.c 35 | 102 | time ./tcc -I. ./ex3.c 35 |
| 97 | 103 | ||
| 98 | ex2: ex2.c | 104 | ex2: ex2.c |
| 99 | gcc $(CFLAGS) -o $@ $< | 105 | $(CC) $(CFLAGS) -o $@ $< |
| 100 | 106 | ||
| 101 | ex3: ex3.c | 107 | ex3: ex3.c |
| 102 | gcc $(CFLAGS) -o $@ $< | 108 | $(CC) $(CFLAGS) -o $@ $< |
| 103 | 109 | ||
| 104 | # Native Tiny C Compiler | 110 | # Native Tiny C Compiler |
| 105 | 111 | ||
| 106 | tcc_g: tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h Makefile | 112 | tcc_g: tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h Makefile |
| 107 | gcc $(CFLAGS) -o $@ $< $(LIBS) | 113 | $(CC) $(CFLAGS) -o $@ $< $(LIBS) |
| 108 | 114 | ||
| 109 | tcc: tcc_g | 115 | tcc: tcc_g Makefile |
| 110 | strip -s -R .comment -R .note -o $@ $< | 116 | strip -s -R .comment -R .note -o $@ $< |
| 111 | 117 | ||
| 112 | # TinyCC runtime libraries | 118 | # TinyCC runtime libraries |
| 113 | libtcc1.o: libtcc1.c | 119 | libtcc1.o: libtcc1.c |
| 114 | gcc -O2 -Wall -c -o $@ $< | 120 | $(CC) -O2 -Wall -c -o $@ $< |
| 115 | 121 | ||
| 116 | bcheck.o: bcheck.c | 122 | bcheck.o: bcheck.c |
| 117 | gcc -O2 -Wall -c -o $@ $< | 123 | $(CC) -O2 -Wall -c -o $@ $< |
| 118 | 124 | ||
| 119 | install: tcc libtcc1.o bcheck.o | 125 | install: tcc_install libinstall |
| 120 | $(INSTALL) -m755 tcc $(prefix)/bin | 126 | |
| 121 | $(INSTALL) tcc.1 $(manpath)/man1 | 127 | tcc_install: tcc libtcc1.o bcheck.o |
| 122 | mkdir -p $(prefix)/lib/tcc | 128 | $(INSTALL) -m755 tcc $(bindir) |
| 123 | mkdir -p $(prefix)/lib/tcc/include | 129 | $(INSTALL) tcc.1 $(mandir)/man1 |
| 124 | $(INSTALL) -m644 libtcc1.o bcheck.o $(prefix)/lib/tcc | 130 | mkdir -p $(libdir)/tcc |
| 131 | mkdir -p $(libdir)/tcc/include | ||
| 132 | $(INSTALL) -m644 libtcc1.o bcheck.o $(libdir)/tcc | ||
| 125 | $(INSTALL) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \ | 133 | $(INSTALL) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \ |
| 126 | tcclib.h $(prefix)/lib/tcc/include | 134 | tcclib.h $(libdir)/tcc/include |
| 127 | 135 | ||
| 128 | clean: | 136 | clean: |
| 129 | rm -f *~ *.o tcc tcc1 tcct tcc_g tcctest.ref *.bin *.i ex2 \ | 137 | rm -f *~ *.o tcc tcc1 tcct tcc_g tcctest.ref *.bin *.i ex2 \ |
| 130 | core gmon.out test.out test.ref a.out tcc_p \ | 138 | core gmon.out test.out test.ref a.out tcc_p \ |
| 131 | *.exe tcc-doc.html \ | 139 | *.exe tcc-doc.html libtcc.a libtcc_test \ |
| 132 | tcctest[1234] test[1234].out | 140 | tcctest[1234] test[1234].out |
| 133 | 141 | ||
| 142 | distclean: clean | ||
| 143 | rm -f config.h config.mak | ||
| 144 | |||
| 134 | # win32 TCC | 145 | # win32 TCC |
| 135 | tcc_g.exe: tcc.c i386-gen.c bcheck.c Makefile | 146 | tcc_g.exe: tcc.c i386-gen.c bcheck.c Makefile |
| 136 | i386-mingw32msvc-gcc $(CFLAGS) -DCONFIG_TCC_STATIC -o $@ $< | 147 | i386-mingw32msvc-gcc $(CFLAGS) -DCONFIG_TCC_STATIC -o $@ $< |
| @@ -140,21 +151,21 @@ tcc.exe: tcc_g.exe · 3 unmodified lines | |||
| 140 | 151 | ||
| 141 | # profiling version | 152 | # profiling version |
| 142 | tcc_p: tcc.c Makefile | 153 | tcc_p: tcc.c Makefile |
| 143 | gcc $(CFLAGS_P) -o $@ $< $(LIBS_P) | 154 | $(CC) $(CFLAGS_P) -o $@ $< $(LIBS_P) |
| 144 | 155 | ||
| 145 | # libtcc generation and example | 156 | # libtcc generation and example |
| 146 | libinstall: libtcc.a | 157 | libinstall: libtcc.a |
| 147 | $(INSTALL) -m644 libtcc.a $(prefix)/lib | 158 | $(INSTALL) -m644 libtcc.a $(libdir) |
| 148 | $(INSTALL) -m644 libtcc.h $(prefix)/include | 159 | $(INSTALL) -m644 libtcc.h $(includedir) |
| 149 | 160 | ||
| 150 | libtcc.o: tcc.c i386-gen.c bcheck.c Makefile | 161 | libtcc.o: tcc.c i386-gen.c bcheck.c Makefile |
| 151 | gcc $(CFLAGS) -DLIBTCC -c -o $@ $< | 162 | $(CC) $(CFLAGS) -DLIBTCC -c -o $@ $< |
| 152 | 163 | ||
| 153 | libtcc.a: libtcc.o | 164 | libtcc.a: libtcc.o |
| 154 | ar rcs $@ $^ | 165 | $(AR) rcs $@ $^ |
| 155 | 166 | ||
| 156 | libtcc_test: libtcc_test.c libtcc.a | 167 | libtcc_test: libtcc_test.c libtcc.a |
| 157 | gcc $(CFLAGS) -I. -o $@ $< -L. -ltcc -ldl | 168 | $(CC) $(CFLAGS) -I. -o $@ $< -L. -ltcc -ldl |
| 158 | 169 | ||
| 159 | libtest: libtcc_test | 170 | libtest: libtcc_test |
| 160 | ./libtcc_test | 171 | ./libtcc_test |
| @@ -171,7 +182,7 @@ instr: instr.o · 10 unmodified lines | |||
| 171 | # tiny assembler testing | 182 | # tiny assembler testing |
| 172 | 183 | ||
| 173 | asmtest.ref: asmtest.S | 184 | asmtest.ref: asmtest.S |
| 174 | gcc -c -o asmtest.ref.o asmtest.S | 185 | $(CC) -c -o asmtest.ref.o asmtest.S |
| 175 | objdump -D asmtest.ref.o > $@ | 186 | objdump -D asmtest.ref.o > $@ |
| 176 | 187 | ||
| 177 | # XXX: we compute tcc.c to go faster during development ! | 188 | # XXX: we compute tcc.c to go faster during development ! |
| @@ -185,7 +196,7 @@ asmtest: asmtest.out asmtest.ref · 7 unmodified lines | |||
| 185 | @if diff -u --ignore-matching-lines="file format" asmtest.ref asmtest.out ; then echo "ASM Auto Test OK"; fi | 196 | @if diff -u --ignore-matching-lines="file format" asmtest.ref asmtest.out ; then echo "ASM Auto Test OK"; fi |
| 186 | 197 | ||
| 187 | instr.o: instr.S | 198 | instr.o: instr.S |
| 188 | gcc -O2 -Wall -g -c -o $@ $< | 199 | $(CC) -O2 -Wall -g -c -o $@ $< |
| 189 | 200 | ||
| 190 | cache: tcc_g | 201 | cache: tcc_g |
| 191 | cachegrind ./tcc_g -o /tmp/linpack -lm bench/linpack.c | 202 | cachegrind ./tcc_g -o /tmp/linpack -lm bench/linpack.c |
| @@ -195,7 +206,7 @@ cache: tcc_g · 3 unmodified lines | |||
| 195 | tcc-doc.html: tcc-doc.texi | 206 | tcc-doc.html: tcc-doc.texi |
| 196 | texi2html -monolithic -number $< | 207 | texi2html -monolithic -number $< |
| 197 | 208 | ||
| 198 | FILES= Makefile Makefile.uClibc \ | 209 | FILES= Makefile Makefile.uClibc configure VERSION \ |
| 199 | README TODO COPYING \ | 210 | README TODO COPYING \ |
| 200 | Changelog tcc-doc.texi tcc-doc.html \ | 211 | Changelog tcc-doc.texi tcc-doc.html \ |
| 201 | tcc.1 \ | 212 | tcc.1 \ |