refactor: Use header file, and update makefile
- Move the definitions and includes to a header file. - Modify the makefile to account for this - add install to makefile
This commit is contained in:
parent
d700ffac51
commit
0385ff1446
24
Makefile
24
Makefile
|
|
@ -1,21 +1,29 @@
|
|||
# Define the variables for the compiler and the flags
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -g
|
||||
CFLAGS = -Wall -g -std=c99 -pedantic
|
||||
|
||||
# Define the libraries to link
|
||||
LIBS = -lsystemd -lbsd
|
||||
|
||||
# Define the source file and the output binary
|
||||
BIN = dexedrine
|
||||
SRC := $(BIN).c
|
||||
prefix = /usr/local
|
||||
exec_prefix = $(prefix)
|
||||
bindir = $(exec_prefix)/bin
|
||||
dexpath = $(bindir)/dexedrine
|
||||
|
||||
.PHONY: all clean install
|
||||
|
||||
# Define the default rule to build the program
|
||||
all: $(BIN)
|
||||
all: dexedrine
|
||||
|
||||
# Define the rule to compile the source file
|
||||
$(BIN): $(SRC)
|
||||
$(CC) $(CFLAGS) $(SRC) -o $(BIN) $(LIBS)
|
||||
dexedrine: dexedrine.c dexedrine.h
|
||||
$(CC) $(CFLAGS) dexedrine.c -o dexedrine $(LIBS)
|
||||
|
||||
# Define the rule to clean the generated files
|
||||
clean:
|
||||
rm -f $(BIN)
|
||||
rm dexedrine
|
||||
|
||||
# Define how to install
|
||||
|
||||
install:
|
||||
install dexedrine $(DESTDIR)$(dexpath)
|
||||
|
|
|
|||
13
dexedrine.c
13
dexedrine.c
|
|
@ -1,15 +1,4 @@
|
|||
#include <bsd/libutil.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <systemd/sd-bus.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/limits.h>
|
||||
|
||||
void handleSigs(int sig);
|
||||
|
||||
#define _cleanup_(f) __attribute__((cleanup(f)))
|
||||
#include "dexedrine.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
|
||||
|
|
|
|||
13
dexedrine.h
Normal file
13
dexedrine.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include <bsd/libutil.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <systemd/sd-bus.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/limits.h>
|
||||
|
||||
void handleSigs(int sig);
|
||||
|
||||
#define _cleanup_(f) __attribute__((cleanup(f)))
|
||||
Loading…
Reference in New Issue
Block a user