Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2fcace2

Browse files
Improve Makefile
1 parent 735436c commit 2fcace2

File tree

2 files changed

+40
-43
lines changed

2 files changed

+40
-43
lines changed

Makefile

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
1-
#DEPS = function.h
2-
#LIB_OBJS = function.o
1+
2+
# Guide used while writing this makefile is
3+
# https://stackoverflow.com/questions/68428103/how-to-create-a-makefile-for-a-c-project-with-multiple-directories
4+
35

46
# https://stackoverflow.com/questions/18007326/how-to-change-default-values-of-variables-like-cc-in-makefile
57
ifeq ($(origin CC),default)
68
CC = gcc
79
endif
810

9-
BLOB_STAMPER_OBJ = blobstamper/blob.o \
10-
blobstamper/helpers.o \
11-
blobstamper/stamp.o \
12-
blobstamper/stamp_arithm.o \
13-
blobstamper/stamp_dict.o \
14-
blobstamper/galley.o \
15-
blobstamper/dict.o \
11+
BLOBSTAMPER_SRC := $(wildcard blobstamper/*.cpp)
12+
BLOBSTAMPER_OBJ := $(addsuffix .o, $(basename $(BLOBSTAMPER_SRC)))
1613

17-
.PHONY: all blob-stamper-all blob-stamper-clean clean test
14+
.PHONY: all blob-stamper-all blob-stamper-clean clean test gagaga
1815

19-
#all: blob-stamper-all test_dict $(WRAPPERS_OBJ)
20-
all: blob-stamper-all
16+
all: $(BLOBSTAMPER_OBJ)
2117
@echo All done!
2218

23-
blob-stamper-all:
24-
$(MAKE) -C blobstamper
19+
blobstamper/%.o: blobstamper/%.cpp
20+
$(CXX) -c -g $(CXXFLAGS) $< -o $@
21+
22+
23+
# blob-stamper-all:
24+
# $(MAKE) -C blobstamper
25+
26+
#%.o: %.cpp $(DEPS)
27+
# $(CXX) -c -g $(CFLAGS) $<
28+
29+
#%.o: %.c $(DEPS)
30+
# $(CC) -c -g $(CXXFLAGS) $<
2531

26-
%.o: %.cpp $(DEPS)
27-
$(CXX) -c -g $(CFLAGS) $<
2832

29-
%.o: %.c $(DEPS)
30-
$(CC) -c -g $(CXXFLAGS) $<
3133

3234
blob-stamper-clean:
35+
rm -f *.o
36+
37+
clean: blob-stamper-clean
3338
$(MAKE) -C blobstamper clean
3439
$(MAKE) -C t clean
3540
$(MAKE) -C libtappp clean
36-
37-
clean: blob-stamper-clean
38-
rm -f *.o
3941
@echo Clean done!
4042

4143
test:
@@ -44,3 +46,10 @@ test:
4446
#test_dict: test_dict.o blob-stamper-all
4547
# $(CXX) $(LDFLAGS) $@.o -o $@ $(BLOB_STAMPER_OBJ)
4648

49+
50+
gagaga:
51+
@echo ------- $(BLOBSTAMPER_OBJ)
52+
53+
#all: blob-stamper-all test_dict $(WRAPPERS_OBJ)
54+
#all: blob-stamper-all $(WRAPPERS_OBJ)
55+
# @echo All done!

t/Makefile

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,26 @@ DEBUG := -ggdb3 -DDEBUG
66
#CXXFLAGS := $(DEBUG) $(WARNINGS) -fPIC
77
PREFIX := /usr/local
88
LIBRARY_VAR := LD_LIBRARY_PATH
9-
TEST_GOALS := ./00-sanity.t \
10-
./001-blob-generic.t \
11-
./050-sized_prt_and_vsato_ptr.t \
12-
./100-stamp-base.t \
13-
./110-stamp-arithm.t \
14-
./120-stamp_dict.t \
15-
./200-dict.t \
16-
./300-galley.t \
179

18-
all: build-libtappp $(TEST_GOALS)
1910

11+
BLOBSTAMPER_SRC := $(wildcard ../blobstamper/*.cpp)
12+
BLOBSTAMPER_OBJ := $(addsuffix .o, $(basename $(BLOBSTAMPER_SRC)))
2013

21-
# FIXME this list dublicates same list in ../Makefile
22-
# should remove it for deduplication
23-
BLOB_STAMPER_OBJ = ../blobstamper/blob.o \
24-
../blobstamper/helpers.o \
25-
../blobstamper/dict.o \
26-
../blobstamper/stamp.o \
27-
../blobstamper/stamp_arithm.o \
28-
../blobstamper/stamp_dict.o \
29-
../blobstamper/galley.o \
14+
TEST_SRC := $(wildcard ./*.cpp)
15+
TEST_BIN := $(addsuffix .t, $(basename $(TEST_SRC)))
3016

3117

18+
all: build-libtappp $(TEST_BIN)
19+
3220
build-libtappp:
3321
$(MAKE) -C ../libtappp
3422

35-
%.t: %.cpp
36-
$(CXX) $(CXXFLAGS) -I../libtappp/include -I.. -o $@ $< $(BLOB_STAMPER_OBJ) -L../libtappp -ltap++
23+
%.t: %.cpp $(BLOBSTAMPER_OBJ)
24+
$(CXX) $(CXXFLAGS) -I../libtappp/include -I.. -o $@ $< $(BLOBSTAMPER_OBJ) -L../libtappp -ltap++
3725

3826
test: all
39-
@echo run_tests.pl $(TEST_GOALS)
40-
@$(LIBRARY_VAR)=../libtappp ../libtappp/run_tests.pl $(TEST_GOALS)
27+
@echo run_tests.pl $(TEST_BIN)
28+
@$(LIBRARY_VAR)=../libtappp ../libtappp/run_tests.pl $(TEST_BIN)
4129

4230
clean:
4331
-rm *.t 2>/dev/null

0 commit comments

Comments
 (0)