forked from alex85k/wingetopt
-
Notifications
You must be signed in to change notification settings - Fork 7
/
GNUmakefile
43 lines (33 loc) · 1.18 KB
/
GNUmakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Copyright 2022 Seagate Technology and/or its Affiliates
# This is a handwritten GNUMakefile for wingetopt
# This was done so as not to collide with the makefile output from CMake when CMake is used.
# This makefile is for projects unable to use cmake or meson, but support GNUMake
# Can convert this to a POSIX makefile if needed. -TJE
NAME=wingetopt
CC ?= cc
SRC_DIR=./src
INC_DIR=-I./src/
CC ?= gcc
AR ?= ar
CFLAGS ?= -Wall -Wextra -c -fPIC -I.
CFLAGS += -c -fPIC -I.
SRC_FILES = $(SRC_DIR)/getopt.c
LIB_OBJ_FILES = $(SRC_FILES:.c=.o)
STATIC_LIB = lib$(NAME).a
SHARED_LIB = lib$(NAME).so
FILE_OUTPUT_DIR=lib
.PHONY: all
all: clean mkoutputdir static
%.o: %.c
$(CC) $(CFLAGS) $(INC_DIR) $< -o $@
static: $(LIB_OBJ_FILES)
rm -f $(FILE_OUTPUT_DIR)/$(STATIC_LIB) $(FILE_OUTPUT_DIR)/$(SHARED_LIB)
$(AR) cq $(FILE_OUTPUT_DIR)/$(STATIC_LIB) $(LIB_OBJ_FILES)
shared: $(LIB_OBJ_FILES)
rm -f $(FILE_OUTPUT_DIR)/$(STATIC_LIB) $(FILE_OUTPUT_DIR)/$(SHARED_LIB)
$(CC) -shared $(LIB_OBJ_FILES) -o $(FILE_OUTPUT_DIR)/$(SHARED_LIB)
clean:
rm -f $(FILE_OUTPUT_DIR)/$(STATIC_LIB) $(FILE_OUTPUT_DIR)/$(SHARED_LIB) *.o $(SRC_DIR)/*.o
rm -rf $(FILE_OUTPUT_DIR)
mkoutputdir:
mkdir -p $(FILE_OUTPUT_DIR)