-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmakefile
68 lines (51 loc) · 1.98 KB
/
makefile
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
###############################################################################
## ##
## Makefile for bash wrapper of the C-function ioctl() ##
## ##
##---------------------------------------------------------------------------##
## File: ~/ioctl/src/makefile ##
## Author: Ulrich Becker ##
## Date: 22.03.2016 ##
###############################################################################
BASEDIR ?= .
EXE_NAME ?= ioctl
SOURCES = ioctl_main.c parse_opts.c
# We need some source files from a other git-repository...
GIT_REPOSITORY_URL = https://raw.githubusercontent.com/UlrichBecker/command_line_option_parser/master/src/
# At the moment this program doesn't have a commandline-option with
# needs obligatory argument, so we can reduce the size of the binary:
PRE_DEFINES = CONFIG_CLOP_NO_REQUIRED_ARG
VPATH = $(BASEDIR)
INCDIR = $(BASEDIR)
CFLAGS ?= -g -O0
CC ?= gcc
PREFIX ?= /usr/local/bin
_CFLAGS += $(CFLAGS)
_CFLAGS += $(addprefix -I,$(INCDIR))
_CFLAGS += $(addprefix -D,$(PRE_DEFINES))
OBJDIR=.obj
OBJ = $(addprefix $(OBJDIR)/,$(addsuffix .o,$(notdir $(basename $(SOURCES)))))
.PHONY: all
all: $(EXE_NAME)
parse_opts.h:
wget $(GIT_REPOSITORY_URL)parse_opts.h
parse_opts.c:
wget $(GIT_REPOSITORY_URL)parse_opts.c
$(OBJDIR):
mkdir $(OBJDIR)
$(OBJDIR)/%.o: %.c $(SOURCES) $(OBJDIR) parse_opts.h
$(CC) -c -o $@ $< $(_CFLAGS)
$(EXE_NAME): $(OBJ)
$(CC) -o $@ $^ $(_CFLAGS) $(LIBS)
.PHONY: clean
clean:
rm -f $(OBJDIR)/*.o $(EXE_NAME) core
rmdir $(OBJDIR)
.PHONY: wipe
wipe: clean
rm parse_opts.*
.PHONY: install
install:
mkdir -p $(PREFIX)
install -s -D -m 755 $(EXE_NAME) $(PREFIX)
#=================================== EOF ======================================