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
|
# Define the variables for the compiler and the flags
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -Wall -g
|
CFLAGS = -Wall -g -std=c99 -pedantic
|
||||||
|
|
||||||
# Define the libraries to link
|
# Define the libraries to link
|
||||||
LIBS = -lsystemd -lbsd
|
LIBS = -lsystemd -lbsd
|
||||||
|
|
||||||
# Define the source file and the output binary
|
prefix = /usr/local
|
||||||
BIN = dexedrine
|
exec_prefix = $(prefix)
|
||||||
SRC := $(BIN).c
|
bindir = $(exec_prefix)/bin
|
||||||
|
dexpath = $(bindir)/dexedrine
|
||||||
|
|
||||||
|
.PHONY: all clean install
|
||||||
|
|
||||||
# Define the default rule to build the program
|
# Define the default rule to build the program
|
||||||
all: $(BIN)
|
all: dexedrine
|
||||||
|
|
||||||
# Define the rule to compile the source file
|
# Define the rule to compile the source file
|
||||||
$(BIN): $(SRC)
|
dexedrine: dexedrine.c dexedrine.h
|
||||||
$(CC) $(CFLAGS) $(SRC) -o $(BIN) $(LIBS)
|
$(CC) $(CFLAGS) dexedrine.c -o dexedrine $(LIBS)
|
||||||
|
|
||||||
# Define the rule to clean the generated files
|
# Define the rule to clean the generated files
|
||||||
clean:
|
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 "dexedrine.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)))
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
|
_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