--- a/Makefile.common
+++ b/Makefile.common
@@ -18,11 +18,9 @@
 LIBHD_MINOR_VERSION	:= $(shell cut -d . -f 2 $(TOPDIR)/VERSION)
 LIBHD_MAJOR_VERSION	:= $(shell cut -d . -f 1 $(TOPDIR)/VERSION)
 
-RPM_OPT_FLAGS	?= -O2
-
 CC	?= gcc
 LD	= ld
-CFLAGS += $(RPM_OPT_FLAGS) -Wall -Wno-pointer-sign -pipe -g $(SHARED_FLAGS) $(EXTRA_FLAGS) -I$(TOPDIR)/src/hd
+CFLAGS += -Wall -Wno-pointer-sign $(SHARED_FLAGS) $(EXTRA_FLAGS) -I$(TOPDIR)/src/hd
 SHARED_FLAGS	= -fPIC
 
 LDFLAGS	+= -Lsrc
--- a/src/Makefile
+++ b/src/Makefile
@@ -12,7 +12,7 @@
 #endif
 
 $(LIBHD): $(OBJS)
-	ar r $@ $?
+	$(AR) r $@ $?
 	@rm -f $(LIBHD_D)
 
 ifdef SHARED_FLAGS
--- a/src/hd/Makefile
+++ b/src/hd/Makefile
@@ -12,4 +12,4 @@
 	@perl -pi -e "s/define\s+HD_MINOR_VERSION\s+\d+/define HD_MINOR_VERSION\t$(LIBHD_MINOR_VERSION)/" $@
 
 $(LIBHD_D): $(OBJS)
-	ar r $(LIBHD) $?
+	$(AR) r $(LIBHD) $?
--- a/src/ids/Makefile
+++ b/src/ids/Makefile
@@ -48,10 +48,10 @@
 IDFILES += src/pci src/storage src/sound src/mouse src/braille
 
 $(LIBHD_D): hd_ids.o
-	ar r $(LIBHD) $?
+	$(AR) r $(LIBHD) $?
 
 check_hd: check_hd.c
-	$(CC) $(CFLAGS) $< -o $@
+	$(CC) $(LDFLAGS) $(CFLAGS) $< -o $@
 
 hd_ids.c: hd_ids.h hd_ids_tiny.h
 
--- a/src/isdn/Makefile
+++ b/src/isdn/Makefile
@@ -5,5 +5,5 @@
 include $(TOPDIR)/Makefile.common
 
 $(LIBHD_D): $(OBJS)
-	ar r $(LIBHD) $?
+	$(AR) r $(LIBHD) $?
 
--- a/src/smp/Makefile
+++ b/src/smp/Makefile
@@ -4,4 +4,4 @@
 include $(TOPDIR)/Makefile.common
 
 $(LIBHD_D): $(OBJS)
-	ar r $(LIBHD) $?
+	$(AR) r $(LIBHD) $?
