1 # Makefile - Build the filesystem access programs 2 # 3 # Copyright (C) 2019, 2021, 2022 Paul Boddie <paul@boddie.org.uk> 4 # 5 # This program is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 # Paths to library sources. 19 20 INC = ../include/e2access 21 SRC = ../lib/src 22 23 # Tool definitions. 24 25 RANLIB = ranlib 26 27 # Compilation and linking flags. 28 29 CFLAGS = -I$(INC) -fPIC # -g 30 LDFLAGS = -lext2fs -L. -le2access # -lcom_err 31 32 # Output programs and libraries. 33 34 E2ACCESS = e2access 35 LIBE2ACCESS = libe2access.a 36 LIBE2ACCESS_SHARED = libe2access.so 37 38 TEST_LISTING = test_listing 39 TEST_REMOVE = test_remove 40 41 TARGETS = $(E2ACCESS) $(LIBE2ACCESS) $(LIBE2ACCESS_SHARED) $(TEST_LISTING) $(TEST_REMOVE) 42 43 # Sources and objects. 44 45 E2ACCESS_SRC = e2access.c file.c 46 E2ACCESS_OBJ = $(E2ACCESS_SRC:.c=.o) 47 48 TEST_LISTING_SRC = test_listing.c 49 TEST_LISTING_OBJ = $(TEST_LISTING_SRC:.c=.o) 50 51 TEST_REMOVE_SRC = test_remove.c 52 TEST_REMOVE_OBJ = $(TEST_REMOVE_SRC:.c=.o) 53 54 LIBE2ACCESS_SRC_ORIG = format.c image.c path.c utils.c 55 56 LIBE2ACCESS_SRC = $(foreach FILE,$(LIBE2ACCESS_SRC_ORIG),$(SRC)/$(FILE)) 57 LIBE2ACCESS_OBJ = $(LIBE2ACCESS_SRC:.c=.o) 58 59 ALL_OBJ = $(E2ACCESS_OBJ) $(LIBE2ACCESS_OBJ) $(TEST_LISTING_OBJ) $(TEST_REMOVE_OBJ) 60 61 # Rules. 62 63 .PHONY: all clean distclean 64 65 all: $(TARGETS) 66 67 clean: 68 rm -f $(ALL_OBJ) $(TARGETS) 69 70 distclean: clean 71 echo "Nothing else to clean." 72 73 $(E2ACCESS): $(E2ACCESS_OBJ) $(LIBE2ACCESS_SHARED) 74 $(CC) $(LDFLAGS) $(E2ACCESS_OBJ) -o $@ 75 76 $(LIBE2ACCESS): $(LIBE2ACCESS_OBJ) 77 $(AR) rc $@ $(LIBE2ACCESS_OBJ) 78 $(RANLIB) $@ 79 80 $(LIBE2ACCESS_SHARED): $(LIBE2ACCESS) $(LIBE2ACCESS_OBJ) 81 $(LD) -shared $(LIBE2ACCESS_OBJ) -o $(LIBE2ACCESS_SHARED) 82 83 $(TEST_LISTING): $(TEST_LISTING_OBJ) $(LIBE2ACCESS_SHARED) 84 $(CC) $(LDFLAGS) $(TEST_LISTING_OBJ) -o $@ 85 86 $(TEST_REMOVE): $(TEST_REMOVE_OBJ) $(LIBE2ACCESS_SHARED) 87 $(CC) $(LDFLAGS) $(TEST_REMOVE_OBJ) -o $@ 88 89 .c.o: 90 $(CC) -c $(CFLAGS) $< -o $@