Index: icewm-1.3.7/src/aapm.h
===================================================================
--- icewm-1.3.7.orig/src/aapm.h	2010-10-31 23:09:36.000000000 +0900
+++ icewm-1.3.7/src/aapm.h	2011-11-29 22:10:21.431306632 +0900
@@ -1,10 +1,10 @@
 
-#if defined(linux) || (defined (__FreeBSD__)) || (defined(__NetBSD__) && defined(i386))
+#if defined(linux) || (defined (__FreeBSD__)) || (defined (__FreeBSD_kernel__))  || (defined(__NetBSD__) && defined(i386))
 
 #include "ywindow.h"
 #include "ytimer.h"
 
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)
 #define APMDEV "/dev/apm"
 #else
 #define APMDEV "/proc/apm"
Index: icewm-1.3.7/src/aapm.cc
===================================================================
--- icewm-1.3.7.orig/src/aapm.cc	2010-10-31 23:09:36.000000000 +0900
+++ icewm-1.3.7/src/aapm.cc	2011-11-29 22:27:39.256438527 +0900
@@ -27,7 +27,7 @@
 #include <stdio.h>
 #include <dirent.h>
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include <sys/file.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
@@ -71,7 +71,7 @@
 
 
 void YApm::ApmStr(char *s, bool Tool) {
-#if defined(__FreeBSD__) && defined(i386)
+#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && defined(i386)
     struct apm_info ai;
 #elif defined __NetBSD__
     struct apm_power_info ai;
@@ -96,7 +96,7 @@
         error = 1;
         return ;
     }
-#if defined(__FreeBSD__) && defined(i386)
+#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && defined(i386)
     if (ioctl(fd,APMIO_GETINFO, &ai) == -1)
     {
         static int error = 0;
@@ -270,7 +270,7 @@
     //assign some default values, in case
     //the file in /proc/acpi will contain unexpected values
     ACstatus = -1;
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
     if (acpiACName && acpiACName[0] != 0) {
         strcat3(buf, "/proc/acpi/ac_adapter/", acpiACName, "/state", sizeof(buf));
         fd = fopen(buf, "r");
@@ -301,7 +301,7 @@
         }
     }
 #else
-    len = sizeof(i);
+    size_t len = sizeof(i);
     if (sysctlbyname("hw.acpi.acline", &i, &len, NULL, 0) >= 0) {
 	if (i == 1)
 	    ACstatus = AC_ONLINE;
@@ -330,7 +330,7 @@
         BATrate = -1;
         BATtime_remain = -1;
 
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
         strcat3(buf, "/proc/acpi/battery/", BATname, "/state", sizeof(buf));
         fd = fopen(buf, "r");
         if (fd == NULL) {
@@ -415,7 +415,7 @@
         if (BATpresent == BAT_PRESENT) { //battery is present now
             if (acpiBatteries[i]->present == BAT_ABSENT) { //and previously was absent
                 //read full-capacity value
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
                 strcat3(buf, "/proc/acpi/battery/", BATname, "/info", sizeof(buf));
                 fd = fopen(buf, "r");
                 if (fd != NULL) {
@@ -460,7 +460,7 @@
         }
         acpiBatteries[i]->present = BATpresent;
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 	close(acpifd);
 #endif
 
@@ -882,7 +882,7 @@
     chargeStatus = 0.0;
 
     //search for acpi info first
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
     n = scandir("/sys/class/power_supply", &de, 0, alphasort);
     if (n < 0) {
         n = scandir("/proc/acpi/battery", &de, 0, alphasort);
